home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / readers / utils / gui4cli / demos / mmedia.gc < prev    next >
Text File  |  1996-10-28  |  11KB  |  332 lines

  1. G4C - by dck 13/1/96
  2.  
  3. ; MULTIMEDIA GUI
  4.  
  5. ; This file contains a GUI for playing graphics & sound together.
  6. ; It uses the following programs, which are not included, but are
  7. ; widely available. All of them are considered to be in the c: directory.
  8.  
  9. ; Viewer : PPShow 4.0 ILBM/ANIM/GIF/JPEG/DataTypes viewer
  10. ;          Copyright © 1991-1994 Nico François (17.2.94)
  11. ;          Additional code by Rafael D'Halleweyn
  12.  
  13. ; Module Player : ProPlay2.exe - 1993 by Kenneth Nilsen / Digital Surface
  14.  
  15. ; Sample Player : SFX (c) 1992 Imagine Software Inc / Trevor Andrews.
  16. ;                 (This is an old program, but very good)
  17.  
  18. ; You can adjust it accordingly for any other players you prefer.
  19. ; most of the command line options will be similar.
  20. ; Run it with : RUN gui4cli MMedia.gc - Or, click on the icon.
  21.  
  22. ; This GUI has two other GUIs that it operates, PPShow.gc and SFX.gc.
  23. ; They are GUIs that offer more options for the respective programs but
  24. ; they can also be loaded and operated on their own.
  25. ; Look at them also to get the full picture of what's going on.
  26.  
  27. ;.... and heeeeere we go...
  28.  
  29.  
  30. ;====================> Global definitions.
  31.  
  32. WINBIG   -1 30 290 145 "Multi-Media!"
  33. wintype  11110001          ; a resizable window
  34. WINOUT   "NIL:"
  35. WinBackground SOLID 3 0    ; You can make a nicer background, believe me..
  36.  
  37.  
  38. ;======> some lines and colored text (we could use other fonts for effect,
  39. ; but I don't know if you have them, so well just leave it as it is)
  40.  
  41. Line 80 130 278 130 1
  42. Line 80 131 278 131 2
  43.  
  44. LINE  8 70 282 70 2
  45. LINE  8 71 282 71 1
  46.  
  47. LINE  8 110 282 110 2
  48. LINE  8 111 282 111 1
  49.  
  50. CTEXT 10 13 "Display" default 8 2 3 000
  51. CTEXT 10 83 "Music" default 8 2 3 000
  52.  
  53. BOX  0 0 0 0 OUT ICONDROP               ; A window sized box
  54.  
  55. ;======> an AppMenu which will open this GUI's window.
  56. ; Any icons chosen will be placed in ppsDummy, but we will not use them,
  57. ; since we have not built into the GUI the ability to distinguish if
  58. ; the files are Graphics, Samples or Mods. It'd be too confusing for now. 
  59.  
  60. xAppMenu GUI-MMedia ppsDummy ON
  61. GuiOpen MMedia.gc
  62.  
  63.  
  64. ;====================> To be done on startup
  65. ; We check if the other 2 GUIs (ppshow.gc and sfx.gc) are loaded or not
  66. ; and if they are we use their values (filenames etc).
  67. ; Otherwise, we set the starting default values of our variables.
  68. ; Don't get confused by this stuff - It's not vital.
  69.  
  70. xONLOAD
  71. setvar ppsDisplay "PPshow"     ; These we set anyway.
  72. setvar ppsmusic "mod"
  73. SETGAD MMedia.gc 3 OFF         ; Set the Music "adjust" button off
  74.  
  75. IfExists GUI ppshow.gc         ; If ppshow.gc has already been loaded
  76.   update MMedia.gc 1 $ppsfile  ; we update the file name
  77.   update MMedia.gc 21 $ppstimes ; update the Times to play
  78.   update MMedia.gc 22 $ppsjifs ; and the Jifs (speed)
  79. else                           ; otherwise...
  80.   GUILOAD GUIs:Demos/ppshow.gc ; we load it, and set the default values..
  81.   setvar ppsjifs  3            ; Jiffs (speed) - less is faster
  82.   setvar ppsJifGad "J=3"       ; Command line option for jifs
  83.   setvar ppstimes 100          ; Times to play animation
  84.   setvar ppsTimesGad "T=100"   ; command line option for times to play
  85.   setvar ppstime 60            ; Time to play each picture
  86.   setvar ppsTimeGad ""         ; Command line option for Time - (OFF)
  87.   setvar ppslace  NL           ; Lace / NoLace
  88.   setvar ppsmouse NOMOUSE      ; Mouse / NoMouse
  89.   setvar ppsfile  ""           ; File(s) to play for ppshow
  90. endif
  91.  
  92. IfExists GUI sfx.gc            ; If sfx.gc is already loaded
  93.   update MMedia.gc 2 $ppsmod   ; update filename
  94. else                           ; otherwise...
  95.   GUILOAD GUIs:Demos/sfx.gc    ; load it, and set defaults
  96.   setvar ppsmod   ""           ; Name of music file (none)
  97.   setvar ppsleft  -l           ; Left speacker
  98.   setvar ppsright -r           ; Right speacker
  99.   setvar ppsvol   64           ; Sample volume
  100.   setvar ppshz    30000        ; Sample rate (speed)
  101.   setvar ppsrep   100          ; No of times to repeat sample
  102.   setvar ppsRepGad "-c 100"    ; Command line option for repeat
  103. endif
  104.  
  105.  
  106. ;==========> On closing, we also close the other 2 GUIs
  107. ; You may not like this - if not, just delete these 3 lines.
  108.  
  109. xONCLOSE
  110. GUICLOSE ppshow.gc         ; (nothing happens if they were not open)
  111. GUICLOSE sfx.gc
  112.  
  113.  
  114. ;=========> On quitting we unload the other 2 GUIs also and delete all 
  115. ; the variables we declared. You may also not like this - delete it.
  116.  
  117. xONQUIT
  118. GUIQuit ppshow.gc         ; (no problem if they were not loaded)
  119. GUIQuit sfx.gc
  120. ; Here, we would normally have to delete all the variables we declared,
  121. ; ... but I can't be bothered for now.
  122.  
  123.  
  124. ;*************************** PPSHOW *************************************
  125.  
  126. ;==================== PPShow adjust ==========================
  127. ; This is a cycler which lets you choose if you want to have ppshow on
  128. ; or off - if off, the graphics files will not be played - only the sound.
  129. ; you could add choices for other graphics players on this cycler, and
  130. ; have dedicated "adjust" GUIs for each of them.
  131.  
  132. xCYCLER 75 5 100 12 "" ppsDisplay
  133. CSTR "PPShow"  "PPShow"
  134. CSTR "OFF"     "Off"
  135. if $ppsDisplay = "Off"
  136.    SETGAD MMedia.gc 5 OFF
  137. else
  138.    SETGAD MMedia.gc 5 ON
  139. endif
  140.  
  141. xBUTTON 180 5 100 12 Adjust..
  142. GadID 5
  143. GUIOPEN ppshow.gc
  144.  
  145.  
  146. ;===================== TIMES & Jiffs Sliders ===========================
  147. ; for animations - note that I use only these two sliders because that's
  148. ; the way I like it. You may change it, by just editing this file.
  149. ; When the user changes the slider, we also update the relevant
  150. ; slider in the ppshow.gc GUI. (nothing will happen if ppshow.gc is not open)
  151.  
  152. xHSLIDER 65 35  185 11 "Times:" ppstimes 1 999 100 "%3ld"
  153. GadID 21
  154. setvar ppsTimesGad "T= $ppstimes" ; This is the full command line option
  155. update ppshow.gc 11 $ppstimes
  156.  
  157.  
  158. ;----------------> JIFS Slider
  159.  
  160. xHSLIDER 65 20  185 11 Jiffs:  ppsjifs  0 10  3   "%2ld"
  161. GadID 22
  162. update ppshow.gc 15 $ppsjifs
  163. setvar ppsJifGad "J= $ppsjifs"
  164.  
  165.  
  166. ;================= File request for PPShow ============================
  167. ; We make a TEXT gadget to show the file name chosen to play (if any)
  168. ; and place a button next to it, which will open a requester and let
  169. ; you choose file(s) - we also update the ppshow.gc TEXT gadget
  170.  
  171. xBUTTON 10 50 20 15 "R"
  172. REQFILE -1 -1 300 -40 "Choose Graphics" MULTI ppsfile sys:
  173. IF $ppsfile = ""
  174.    update MMedia.gc  1 "No file chosen"
  175.    update ppshow.gc  1 "No file chosen"
  176. else
  177.    update MMedia.gc  1 $ppsfile
  178.    update ppshow.gc  1 $ppsfile
  179. endif
  180.  
  181. TEXT 35 50 245 15 "No file chosen" 80 BOX
  182. GADID 1
  183.  
  184.  
  185. ;***************************** MUSIC ***********************************
  186. ; In this section we choose whether we want the mod player (ProPlay2.exe)
  187. ; or the sample player (sfx) - the logic and gadgets are about the same
  188. ; as for ppshow above.
  189.  
  190. ;====================> Cycler to let us choose the music player program
  191.  
  192. xCYCLER 75 75 100 12 " " ppsmusic
  193. CSTR "MODULE"  "mod"
  194. CSTR "SAMPLE"  "samp"
  195. CSTR "OFF"     ""
  196. if $ppsmusic = samp          ;Only samples can be adjusted.
  197.    SETGAD MMedia.gc 3 ON
  198. else
  199.    SETGAD MMedia.gc 3 OFF
  200. endif
  201.  
  202. ;====================> Call the gui for adjusting sfx parameters
  203.  
  204. xBUTTON 180 75 100 12 Adjust..
  205. GADID 3                         ; give it an ID so we can SETGAD it.
  206. GUIOPEN sfx.gc
  207.  
  208. ;===================> Text & LoadFile button for music to play with anim
  209. ;                     we also update the sfx.gc GUI
  210.  
  211. xBUTTON 10 90 20 15 "R"
  212. REQFILE -1 -1 300 -40 "Choose Music" LOAD ppsmod sys:
  213. IF $ppsmod = ""
  214.    update MMedia.gc  2 "No file chosen" 
  215.    update sfx.gc     2 "No file chosen"
  216. else   
  217.    update MMedia.gc  2 $ppsmod
  218.    update sfx.gc     2 $ppsmod
  219. endif
  220.  
  221.  
  222. TEXT 35 90 245 15 "No Music file chosen" 150 BOX
  223. GADID 2
  224.  
  225.  
  226. ;**************************** EXECUTE COMMAND LINES ******************
  227.  
  228. ;===================> Run The Multi Media Super Show :)
  229.  
  230. xICON 10 113 guis:info/Play                    ; gosub the relevant routines
  231. SetWinTitle MMedia.gc "Loading Players..."
  232. gosub MMedia.gc PlayMusic
  233. gosub MMedia.gc PlayGraphics
  234. SetWinTitle MMedia.gc "Multi-Media!"
  235.  
  236. ;--------------> ROUTINE : Play music if not OFF and if there is a file
  237.  
  238. xROUTINE PlayMusic
  239. if $ppsmusic = OFF
  240.    return
  241. endif
  242. if $ppsmod = ""
  243.    update MMedia.gc 2 "No Music file."
  244.    return
  245. endif
  246. if $ppsmusic = "mod"
  247.    RUN 'run >NIL: dh0:graphics/music/proplay2.exe $ppsmod'
  248. else
  249.    RUN 'run >NIL: sfx $ppsVolGad $ppsRepGad $ppsHzGad $ppsleft $ppsright $ppsscript $ppsdisk $ppsquiet $ppsmod'
  250. endif
  251.  
  252. ;--------------> ROUTINE : Play graphics if not OFF and if there is a file
  253.  
  254. xROUTINE PlayGraphics
  255. if $ppsDisplay != OFF
  256.   if $ppsfile != ""
  257.     RUN 'ppshow >NIL: $ppsfile $ppsJifGad $ppsTimeGad $ppsTimesGad $ppsmode $ppsres $ppsplay $ppslace $ppsflik $ppsdatt $ppsmouse $ppsoscn $ppscycle $ppsnoan'
  258.   endif
  259. endif
  260.  
  261.  
  262. ;****************** SAVE AND REPLAY COMMAND LINES *********************
  263. ; These are 2 buttons for saving and replaying the command lines we have formed
  264. ; with our GUIs - You can make slideshows with music etc..
  265. ; - To save them, we write the command lines into a env:variable and copy to file.
  266. ; - To replay them, we just execute the saved file.
  267.  
  268. xBUTTON 80 114 100 14 "Save.."
  269.  
  270. setvar ppsSaveFile ""            ; Get name of file to save in.
  271. ReqFile -1 -1 300 -40 "Save Commands" SAVE ppsSaveFile ""
  272.  
  273. if $ppsSaveFile = ""            ; User canceled
  274.    Stop
  275. endif
  276. SetWinTitle MMedia.gc "Saving..."
  277. SetVar .ppsSave ""               ; Put command lines into an env: variable
  278.                                  ; save them afterwards - see later on..
  279. if $ppsmusic != OFF
  280.    if $ppsmod != ""
  281.       if $ppsmusic = "mod"
  282.          SetVar .ppsSave 'run >NIL: proplay2.exe $ppsmod'
  283.       else
  284.          SetVar .ppsSave 'run >NIL: sfx $ppsVolGad $ppsRepGad $ppsHzGad $ppsleft $ppsright $ppsscript $ppsdisk $ppsquiet $ppsmod'
  285.       endif
  286.    endif
  287. endif
  288.  
  289. append env:.ppsSave "\n"         ; Append a newline character (ENTER)
  290.  
  291. if $ppsDisplay != OFF
  292.   if $ppsfile != ""
  293.     append env:.ppsSave 'run >NIL: ppshow $ppsfile $ppsJifGad $ppsTimeGad $ppsTimesGad $ppsres $ppsplay $ppslace $ppsflik $ppsdatt $ppsmouse $ppsoscn $ppscycle $ppsnoan'
  294.   endif
  295. endif
  296.  
  297. if $.ppsSave != '\n'                 ; If there is something to save - save it!
  298.    CLI 'Copy >NIL: env:.ppsSave TO $ppsSaveFile'
  299. endif
  300.  
  301. SetWinTitle MMedia.gc "Multi-Media!"
  302.  
  303.  
  304. ;-----------------> Replay a previously saved file (just execute it)
  305.  
  306. xBUTTON 180 114 100 14 "Replay.."
  307. SetVar ppsSaveFile ""
  308. ReqFile -1 -1 300 -40 "Load Commands" LOAD ppsSaveFile ""
  309. if $ppsSaveFile > ""     
  310.    SetWinTitle MMedia.gc "Loading...."
  311.    RUN 'Execute >NIL: $ppsSaveFile'
  312.    SetWinTitle MMedia.gc "Multi-Media!"
  313. endif
  314.  
  315. ;****************************** The END ********************************
  316.  
  317. ;====================== and that's all it takes ! =========================
  318.  
  319. ; Yes, I know.. SCALA 400, it ain't - but it's not bad either.
  320.  
  321. ; I've tried to keep things simple (!!??) You could add much more to this
  322. ; GUI (and the supporting ones), such as other sound/graphics players
  323. ; file recognition (with the H= operator) etc.
  324.  
  325. ; Also, if you find any players which have ARexx ports you could make
  326. ; this an interactive GUI - i.e. change the volume while the sample is
  327. ; playing for example etc. Imagination, is the only barrier.
  328.  
  329. ; Am I tiring you ?
  330. ; dck
  331.  
  332.